<template>
	<view class="container white-bg">
		<u-form :model="form" :border-bottom="false" ref="uForm" label-width="auto">
			<u-form-item label-width="120" required="true" label="结算标准" prop="salary_standard_chi">
				<u-input v-model="form.salary_standard_chi" placeholder="请输入按尺结算的标准"/>
			</u-form-item>
			<u-form-item label-width="120" required="true" label="结算标准" prop="salary_standard_day">
				<u-input v-model="form.salary_standard_day" placeholder="请输入按天结算的标准"/>
			</u-form-item>
		</u-form>
		
		<u-button class='u-margin-40' :disabled="submitBtnDis" type="primary" @click="submit">确认修改</u-button>
		<u-top-tips ref="uTips"></u-top-tips>
	</view>
</template>

<script>
	import {mapState} from "vuex";
	export default {
		data() {
			return {
				submitBtnDis:false,
				projectID:"",
				form:{
					salary_standard_chi:"", //工资标准(按尺)
					salary_standard_day:"" //工资标准(按天)
				},
				rules: {
					salary_standard_chi:[
						{
							required:true,
							message:"请输入按尺结算工资标准",
							trigger:['blur','change']
						}
					],
					salary_standard_day:[
						{
							required:true,
							message:"请输入按天结算工资标准",
							trigger:['blur','change']
						}
					]
				}
			}
		},
		computed:{
			...mapState({
				token:"token"
			})
		},
		onLoad(params) {
			this.projectID = params.projectID;
		},
		// 设置校验规则
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
		methods: {
			submit(){
				this.$refs.uForm.validate(async valid => {
					if (valid) {
						let {form,token,projectID} = this;
						this.submitBtnDis = true;
						this.$loading("正在修改")
						let res = await this.$network({
							api: "main",
							data:{
								action:"projectAdmin/updateSalaryStandard",
								data:{form,token,projectID}
							}
						});
						uni.hideLoading();
						this.submitBtnDis = false;
						if (res.status === 0) {
							this.$refs.uTips.show({
								title: '修改成功',
								type: 'success'
							})
						}
					}
				})
			}
		}
	}
</script>

<style>

</style>
